package com.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.commom.Result;
import com.example.demo.entity.LendRecord;
import com.example.demo.mapper.LendRecordMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 借阅管理
 */
@RestController
@RequestMapping("/api/LendRecord1")
@Slf4j
public class LendRecordController1 {
    @Resource
    LendRecordMapper LendRecordMapper;

    /**
     * 更新借阅记录
     * @param lendRecord
     * @return
     */
    @PutMapping
    public Result<?> update2(@RequestBody LendRecord lendRecord) {
        log.info("更新借阅记录：{}", lendRecord);
        UpdateWrapper<LendRecord> updateWrapper = new UpdateWrapper<>();
        // 设置查询条件
        updateWrapper.eq("isbn", lendRecord.getIsbn()).eq("reader_id", lendRecord.getReaderId()).eq("borrownum", lendRecord.getBorrownum());
        LendRecord lendrecord = new LendRecord();
        lendrecord.setReturnTime(lendRecord.getReturnTime());// 设置还书时间
        lendrecord.setStatus(lendRecord.getStatus());// 设置是否归还
        LendRecordMapper.update(lendrecord, updateWrapper);
        return Result.success();
    }


}
